import { axios } from '@/service/service'
import { PageQueryParam } from '../common/types'

export function getUserInfoReq(): any {
  return axios({
    url: '/api-user/users/current',
    method: 'get'
  })
}

export function logoutReq(params: any): any {
  return axios({
    url: '/api-uaa/oauth/remove/token',
    method: 'get',
    params
  })
}

export function modPwdReq(data: any): any {
  return axios({
    url: '/api-user/users/password',
    method: 'post',
    data: data
  })
}

export function modUserInfoReq(data: any): any {
  return axios({
    url: '/api-user/users/updateUser',
    method: 'post',
    data: data
  })
}

export function updateUserHeadImgReq(params: any): any {
  return axios({
    url: '/api-user/users/updateHeadImgUrl',
    method: 'get',
    params
  })
}

export function getRolesReq(type: number): any {
  return axios({
    url: `/api-user/roles/${type}`,
    method: 'get'
  })
}

export function getSysUserListReq(params: PageQueryParam): any {
  return axios({
    url: '/api-user/users/findUsers',
    method: 'get',
    params
  })
}

export function getProUserListReq(params: PageQueryParam): any {
  return axios({
    url: '/api-user/users/findUsersOnPro',
    method: 'get',
    params
  })
}

export function updateUserStateReq(params: any): any {
  return axios({
    url: '/api-user/users/updateEnabled',
    method: 'get',
    params
  })
}

export function updateUserRoleReq(userId: number, roleIds: any[]): any {
  return axios({
    url: `/api-user/users/${userId}/roles`,
    method: 'post',
    data: roleIds
  })
}

export function updateUserDepartmentReq(params: any): any {
  return axios({
    url: '/api-user/users/updateDepartment',
    method: 'get',
    params
  })
}

export function resetPwdReq(id: number): any {
  return axios({
    url: `/api-user/users/${id}/password`,
    method: 'get'
  })
}
export function createUserReq(data: any): any {
  return axios({
    url: '/api-user/users/create',
    method: 'post',
    data
  })
}

export function searchUserByUsernameReq(params: any): any {
  return axios({
    url: '/api-user/users/search',
    method: 'get',
    params
  })
}
